
function repair(i) {
	if (i >= 0 && i <= 9) {
		return "0" + i;
	} else {
		return i;
	}
};
//date参数参考：'yyyy-MM-dd HH:mm:ss','new Date().getTime()'
//format默认：'yyyy-MM-dd HH:mm:ss',参考写法'yyyy年MM月-dd日 hh:mm:ss'
export function formatDateTime(date, format = 'yyyy-MM-dd hh:mm:ss') {
	date = new Date(date);
	var year = date.getFullYear(),
		month = repair(date.getMonth() + 1), //月份是从0开始的
		day = repair(date.getDate()),
		hour = repair(date.getHours()),
		min = repair(date.getMinutes()),
		seconds =repair(date.getSeconds()),
		milliseconds =repair(date.getMilliseconds()),
		quarter = Math.floor((date.getMonth() + 3) / 3), // 季度
		a = date.getHours() < 12 ? '上午' : '下午', // 上午/下午
		A = date.getHours() < 12 ? 'AM' : 'PM'; // AM/PM
	var formatedDate = format.replace(/yyyy/g, year)
		.replace(/MM/g, month)
		.replace(/dd/g, day)
		.replace(/hh/g, hour)
		.replace(/mm/g, min)
		.replace(/ss/g, seconds);
	console.log(formatedDate);
	return formatedDate;
}
export function getUrlParams(name) {
	let reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
	let param = window.location.search.substr(1).match(reg);
	return param && param[2];
}